package com.ruoyi.project.app.controller;


import ai.advance.cmp.api.client.bean.ResponseBean;
import ai.advance.cmp.api.client.bean.dto.ContactDTO;
import ai.advance.cmp.api.client.bean.dto.OrderDTO;
import ai.advance.cmp.api.client.bean.dto.TrafficUserDTO;
import ai.advance.cmp.api.client.bean.dto.query.OrderQueryDTO;
import ai.advance.cmp.api.client.bean.dto.query.RepaymentScheduleQueryDTO;
import ai.advance.cmp.api.client.enums.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.app.service.AppMyService;
import com.ruoyi.project.app.util.*;
import com.ruoyi.project.beautyflower.BfUtil;
import com.ruoyi.project.beautyflower.FaceScoreUtil;
import com.ruoyi.project.beautyflower.loanApplication.domain.LoanApplication;
import com.ruoyi.project.beautyflower.loanApplication.service.LoanApplicationServiceImpl;
import com.ruoyi.project.beautyflower.member.domain.Member;
import com.ruoyi.project.beautyflower.member.mapper.MemberMapper;
import com.ruoyi.project.beautyflower.member.service.MemberServiceImpl;
import com.ruoyi.project.beautyflower.order.domain.Order;
import com.ruoyi.project.beautyflower.order.service.OrderServiceImpl;
import com.ruoyi.project.beautyflower.userBankcard.domain.UserBankcard;
import com.ruoyi.project.beautyflower.userBankcard.service.UserBankcardServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 第三方接口模块
 */
@RestController
@RequestMapping("/app/bf/")
@Api(tags = "第三方接口模块")
public class AppBeautyFlowerController {

    @Autowired
    private OrderServiceImpl orderService;
    @Autowired
    private LoanApplicationServiceImpl loanApplicationService;

    @Autowired
    private MemberServiceImpl memberService;

    @Autowired
    private AppMyService appMyService;
    @Autowired
    private UserBankcardServiceImpl userBankcardService;
    /**
     * 查询放款结果
     * @param params
     * @return
     */
    @PostMapping("queryDisburseResult")
    @ApiOperation(notes = "queryDisburseResult", value = "查询放款结果")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string")
    })
    public Object queryDisburseResult(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        return new XResult("查询成功", BfUtil.queryDisburseResult(params.get("userId")));
    }


    /**
     * 根据订单号查询订单信息
     * @param params
     * @return
     */
    @PostMapping("queryOrderResult")
    @ApiOperation(notes = "queryOrderResult", value = "根据订单号查询订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string")
    })
    public Object queryOrderResult(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        OrderQueryDTO orderQueryDTO=new OrderQueryDTO();
        orderQueryDTO.setOrderId(params.get("orderId"));
        orderQueryDTO.setUserId(params.get("userId"));
        return new XResult("查询成功", BfUtil.queryOrderResult(orderQueryDTO));
    }


//    /**
//     * 根据订单号查询订单信息
//     *
//     * @param params
//     * @return
//     */
//    @PostMapping("queryOrderResult")
//    @ApiOperation(notes = "queryOrderResult", value = "根据订单号查询订单信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "orderId", value = "订单id", required = true, paramType = "query", dataType = "string"),
//            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string")
//    })
//    public Object queryOrderResult(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request) {
//        OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
//        orderQueryDTO.setOrderId(params.get("orderId"));
//        orderQueryDTO.setUserId(params.get("userId"));
//
//        ResponseBean responseBean = BfUtil.queryOrderResult(orderQueryDTO);
//        if (responseBean != null && responseBean.getData() != null) {
//            try {
//                //解析给出起止时间数据
//                JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(responseBean.getData()));
//                OrderStatus orderStatus = OrderStatus.valueOf(jsonObject.getString("orderStatus"));
//                BigDecimal applyAmount = jsonObject.getBigDecimal("applyAmount");
//                Integer installments = jsonObject.getInteger("installments");
//
//                if (orderStatus == OrderStatus.ONGOING || orderStatus == OrderStatus.OVERDUE || orderStatus == OrderStatus.COMPLETED) {
//                    //查询起止时间
//                    ResponseBean trailResponse = BfUtil.trailRepaymentSchedule(createTrailParam(applyAmount, installments));
//                    JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(trailResponse.getData()));
//
//                    jsonObject.put("showStartDate", jsonArray.getJSONObject(0).getString("interestStartDate"));
//                    jsonObject.put("showEndDate", jsonArray.getJSONObject(jsonArray.size() - 1).getString("interestEndDate"));
//                    responseBean.setData(jsonObject);
//                    return new XResult("查询成功", responseBean);
//                }
//            } catch (Exception e) {
//                log.error("解析订单详情出错, orderId ={}, userId={} ,Exception={}", params.get("orderId"), params.get("userId"), e);
//                return new XResult("查询成功", responseBean);//不显示起止时间
//            }
//        }
//        return new XResult("查询失败");
//    }
//
//    private static Map<String, Object> createTrailParam(BigDecimal trailAmount, Integer installments) {
//        Map<String, Object> map = new HashMap();
//        map.put("installments", installments);
//        map.put("trialAmount", trailAmount);
//        map.put("billDate", 10);
//        return map;
//    }


    /**
     * 根据订单号查询还款计划
     * @param params
     * @return
     */
    @PostMapping("queryRepaymentScheduleResult")
    @ApiOperation(notes = "queryRepaymentScheduleResult", value = "根据订单号查询还款计划")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string")
    })
    public Object queryRepaymentScheduleResult(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        RepaymentScheduleQueryDTO repaymentScheduleQueryDTO =new RepaymentScheduleQueryDTO();
        repaymentScheduleQueryDTO.setOrderId(params.get("orderId"));
        repaymentScheduleQueryDTO.setUserId(params.get("userId"));
        return new XResult("查询成功", BfUtil.queryRepaymentScheduleResult(repaymentScheduleQueryDTO));
    }
    /**
     * 根据用户id查询用户额度信息
     * @param params
     * @return
     */
    @PostMapping("queryCreditLineResult")
    @ApiOperation(notes = "queryCreditLineResult", value = "根据用户id查询用户额度信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string")
    })
    public Object queryCreditLineResult(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        return new XResult("查询成功", BfUtil.queryCreditLineResult(params.get("userId")));
    }

    /**
     * 还款计划试算
     * @param params
     * @return
     */
    @PostMapping("trailRepaymentSchedule")
    @ApiOperation(notes = "trailRepaymentSchedule", value = "还款计划试算")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "installments", value = "还款总期数", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "trialAmount", value = "贷款金额", required = true, paramType = "query", dataType = "String")
    })
    public Object trailRepaymentSchedule(@RequestParam @ApiIgnore Map<String, Object> params, @ApiIgnore HttpServletRequest request)  {
        return new XResult("查询成功", BfUtil.trailRepaymentSchedule(params));
    }
    /**
     * 还款计划试算测试
     * @param params
     * @return
     */
    @PostMapping("trailRepaymentScheduleSum")
    @ApiOperation(notes = "trailRepaymentScheduleSum", value = "还款计划试算测试")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "installments", value = "还款总期数", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "trialAmount", value = "贷款金额", required = true, paramType = "query", dataType = "String")
    })
    public Object trailRepaymentScheduleSum(@RequestParam @ApiIgnore Map<String, Object> params, @ApiIgnore HttpServletRequest request)  {
        return new XResult("查询成功", BfUtil.trailRepaymentScheduleSum(params));
    }
    /**
     * 保存订单
     * @param params
     * @return
     */
    @PostMapping("saveOrder")
    @ApiOperation(notes = "saveOrder", value = "保存订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "trialAmount", value = "贷款金额", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "installments", value = "贷款期数", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankAccountName", value = "银行账户名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankCardNumber", value = "银行卡号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankName", value = "银行名称", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankMobileNumber", value = "银行卡绑定的手机号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "idNumber", value = "用户的证件号码", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "订单类型(1:天美贷，2:颜值贷)", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "purpose", value = "借款用途", required = true, paramType = "query", dataType = "String")
    })
    public Object saveOrder(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        Calendar calendar = Calendar.getInstance();
        OrderDTO orderDTO = new OrderDTO();
       String contractNo= OrderCoderUtil.toCode(Long.parseLong(params.get("userId")));//贷款合同编号
        Integer userId=Integer.valueOf(params.get("userId"));
        List<LoanApplication> loanApplicationList=loanApplicationService.selectLoanApplicationByUsetId(userId);
        if(loanApplicationList!=null&&loanApplicationList.size()>0){
            LoanApplication loanApplication=loanApplicationList.get(0);
            loanApplication.setContractNo(contractNo);
            loanApplicationService.updateLoanApplication(loanApplication);
        }
        params.put("contractNo",contractNo);
        String orderId="TMH" + GenerateNum.getInstance().GenerateOrder();//订单编号
        params.put("orderId",orderId);
        orderDTO.setContractStatus(ContractStatus.EFFECTIVE.name());//合同状态
        Map<String, Object> map= Maps.newHashMap();//用于查询合同金额
        map.put("installments",params.get("installments"));//申请期数
        map.put("trialAmount",params.get("trialAmount"));//贷款金额
        double price=BfUtil.trailRepaymentScheduleSum(map);//合同金额
        params.put("contractAmount",price+"");//合同金额
        ResponseBean responseBean=BfUtil.queryCreditLineResult(params.get("userId"));//查询用户贷款余额
        if(responseBean.getData()!=null){
            Map<String,Object> map1=(Map<String,Object>)responseBean.getData();
            params.put("loanBalance",map1.get("remainAmount")+"");
        }else{
            params.put("loanBalance",0.0D+"");
        }
        ResponseBean responseBean1=BfUtil.createOrder(params);
        if(responseBean1.getCode().equals("SUCCESS")){
            Order order=new Order();
            order.setMemberId(Integer.valueOf(params.get("userId")));
            order.setOrderNumber(orderId);
            order.setOrderTime(DateUtils.getTime());
            order.setLoanAmount(Double.parseDouble(params.get("trialAmount")));
            order.setMobile(params.get("bankMobileNumber"));
            order.setStatus("DISBURSING");
            order.setOrderType(Integer.parseInt(params.get("orderType")));
            order.setOrderPeriods(Integer.parseInt(params.get("installments")));
            order.setBankCardNumber(params.get("bankCardNumber"));
            order.setBankName(params.get("bankName"));
            order.setPurpose(params.get("purpose"));
            orderService.insertOrder(order);
            UserBankcard userBankcard= userBankcardService.selectUserBankcardByBankCardNumber(params.get("bankCardNumber"),"1");
            if(userBankcard!=null){
                userBankcard.setStatus(2);
                userBankcardService.updateUserBankcard(userBankcard);
            }
            return new XResult("订单创建成功",responseBean1);
        }else{
            return new XResult("订单生成失败");
        }
    }

    /**
     * 添加联系人
     * @param params
     * @return
     */
    @PostMapping("addContact")
    @ApiOperation(notes = "addContact", value = "添加联系人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "contactList", value = "联系人集合", required = true, paramType = "query", dataType = "String"),
    })
    public Object addContact(@RequestParam @ApiIgnore Map<String, Object> params, @ApiIgnore HttpServletRequest request) throws Exception {
        TrafficUserDTO users=new TrafficUserDTO();
        Member member=memberService.selectMemberById(Integer.parseInt(params.get("userId")+""));
        Map<String,Object> carMap= Maps.newHashMap();
        if(member.getCarId().length()==18){
            carMap= CardUtil.getCarInfo(member.getCarId());
        }else{
            carMap=CardUtil.getCarInfo15W(member.getCarId());
        }
        users.setUserId(member.getId()+"");
        users.setIdNumber(member.getCarId());
        users.setName(member.getName());
        users.setMobileNumber(member.getMobile());
        users.setGender(carMap.get("sex")+"");
        List<ContactDTO> contactDTOList = Lists.newArrayList();
        JSONArray jsonArray = JSON.parseArray(params.get("contactList")+"");
        //遍历方式2
        for (Object obj : jsonArray) {
            JSONObject jsonObject = (JSONObject) obj;
            ContactDTO contactDTO=new ContactDTO();
            contactDTO.setContactMobileNumber(jsonObject.getString("contactName"));
            contactDTO.setContactName(jsonObject.getString("contactMobileNumber"));
            contactDTO.setIsEmergencyContact(true);
            contactDTOList.add(contactDTO);
        }
        return new XResult("操作成功", BfUtil.updateUserContracts(users,contactDTOList));
    }

    /**
     * 保存预授信额度信息
     * @param params
     * @return
     */
    @PostMapping("createCreditLinePrecheck")
    @ApiOperation(notes = "createCreditLinePrecheck", value = "保存预授信额度信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "userName", value = "用户姓名", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "idNumber", value = "身份证号", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "contractAmount", value = "额度协议金额", required = true, paramType = "query", dataType = "string")
    })
    public Object createCreditLinePrecheck(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  throws JsonProcessingException {
        BfUtil.createCreditLinePrecheck(params);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return new XResult("操作成功",BfUtil.queryCreditLinePrecheckResult(params.get("userId")));
    }


    /**
     * 保存授信额度信息
     * @param params
     * @return
     */
    @PostMapping("createCreditLine")
    @ApiOperation(notes = "createCreditLine", value = "保存授信额度信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "借款人姓名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "idNumber", value = "借款人证件号码", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "contractAmount", value = "额度协议金额", required = true, paramType = "query", dataType = "String"),
    })
    public Object createCreditLine(@RequestParam @ApiIgnore Map<String, String> params, @ApiIgnore HttpServletRequest request)  {
        String contractNo= OrderCoderUtil.toCode(Long.parseLong(params.get("userId")));//授信协议合同编号
        params.put("contractNo",contractNo);
        ResponseBean responseBean=BfUtil.createCreditLine(params);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Map<String,Object> map=Maps.newHashMap();
        List<LoanApplication> loanApplicationList=loanApplicationService.selectLoanApplicationByUsetId(Integer.valueOf(params.get("userId")));
        if(loanApplicationList!=null && loanApplicationList.size()>0){
            map.put("borrowingTime",loanApplicationList.get(0).getCreateTime());//借款申请时间
        }
        map.put("bfdata",BfUtil.queryCreditLineSecondDecisionResult(params.get("userId"),contractNo));
        return new XResult("操作成功",map);
    }
    /**
     * 天美贷用户还款
     * @param params
     * @return
     */
    @PostMapping("createNotifyRepayment")
    @ApiOperation(notes = "createNotifyRepayment", value = "天美贷用户还款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "借款人姓名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "installments", value = "还款总期数", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "repaymentAmount", value = "还款金额", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankAccountName", value = "银行账户名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankCardNumber", value = "银行卡号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankName", value = "银行名称", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankMobileNumber", value = "银行卡绑定的手机号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "details", value = "提前还款详细（json字符串）后面字段属于details里面的参数", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "orderId", value = "订单id", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "installmentNo", value = "还款分期号", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "duePrincipalAmount", value = "应还款本金", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "repaymentPrincipalAmount", value = "实际还款本金", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "repaymentInterestAmount", value = "实际还款利息", required = true, paramType = "query", dataType = "String"),
    })
    public Object createNotifyRepayment(@RequestParam @ApiIgnore Map<String, Object> params, @ApiIgnore HttpServletRequest request)  {
        String contractNo= OrderCoderUtil.toCode(Long.parseLong(params.get("userId")+""));//某次通知还款动作的惟一标识
        params.put("actionId",contractNo);
        System.out.println("某次通知还款动作的惟一标识"+contractNo);
        ResponseBean responseBean=BfUtil.createNotifyRepayment(params);
        if(responseBean.getCode().equals("SUCCESS")){
            try {
                appMyService.insertPaymentHistory(Integer.parseInt(params.get("userId")+""),params.get("bankCardNumber")+"",params.get("bankName")+"",contractNo,params.get("details")+"");
            } catch (NumberFormatException e) {
                throw new XException("参数异常，请检查！");
            }
            return new XResult("操作成功",responseBean);
        }else{
            return new XResult("操作失败");
        }
    }


    /**
     * 颜值贷用户还款
     * @param params
     * @return
     */
    @PostMapping("faceScoreCreateNotifyRepayment")
    @ApiOperation(notes = "faceScoreCreateNotifyRepayment", value = "颜值贷用户还款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "借款人姓名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "installments", value = "还款总期数", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "repaymentAmount", value = "还款金额", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankAccountName", value = "银行账户名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankCardNumber", value = "银行卡号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankName", value = "银行名称", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "bankMobileNumber", value = "银行卡绑定的手机号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "details", value = "提前还款详细（json字符串）后面字段属于details里面的参数", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "orderId", value = "订单id", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "installmentNo", value = "还款分期号", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "duePrincipalAmount", value = "应还款本金", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "repaymentPrincipalAmount", value = "实际还款本金", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "repaymentInterestAmount", value = "实际还款利息", required = true, paramType = "query", dataType = "String"),
    })
    public Object faceScoreCreateNotifyRepayment(@RequestParam @ApiIgnore Map<String, Object> params, @ApiIgnore HttpServletRequest request)  {
        String contractNo= OrderCoderUtil.toCode(Long.parseLong(params.get("userId")+""));//某次通知还款动作的惟一标识
        params.put("actionId",contractNo);
        System.out.println("某次通知还款动作的惟一标识"+contractNo);
        ResponseBean responseBean=FaceScoreUtil.createNotifyRepayment(params);
        if(responseBean.getCode().equals("SUCCESS")){
//            try {
//                appMyService.insertPaymentHistory(Integer.parseInt(params.get("userId")+""),params.get("bankCardNumber")+"",params.get("bankName")+"",contractNo,params.get("details")+"");
//            } catch (NumberFormatException e) {
//                throw new XException("参数异常，请检查！");
//            }
            return new XResult("操作成功",responseBean);
        }else{
            return new XResult("操作失败",responseBean);
        }
    }
}
